package io.lxw.test.controller;

import com.detabes.search.es.service.EsSearchService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.Arrays;

/**
 * ElasticSearch控制器
 *
 * @author 154594742@qq.com
 * @date 2021/3/5 10:02
 */

@RestController
@RequestMapping("elasticSearch")
public class ElasticSearchController {

	private final EsSearchService esSearchService;

	public ElasticSearchController(EsSearchService esSearchService) {
		this.esSearchService = esSearchService;
	}


	@PostMapping("search")
	public Object search(String index, Integer startPage, Integer pageSize) throws IOException {

		return esSearchService.page(Arrays.asList(index.split(",")), startPage, pageSize);
	}

}
